package fr.mywiki.business.structure;

import java.util.Collection;

import junit.framework.TestCase;

/**
 * Testing StructureManager.
 */
public class StructureManagerTest extends TestCase {
	/** Testing structure creation */
	public void testStructureCreation() {
		// Create new elements
		StructureLite root1, unite1, unite2, atelier1, atelier2;
		try {
			root1 = StructureManager.createStructure("Root1", null);
			StructureManager.createStructure("Root2", null);

			unite1 = StructureManager.createStructure("Unite1", root1);
			unite2 = StructureManager.createStructure("Unite2", root1);

			atelier1 = StructureManager.createStructure("Atelier1", unite1);
			atelier2 = StructureManager.createStructure("Atelier2", unite2);

			StructureManager.createStructure("Equipe1", atelier1);
			StructureManager.createStructure("Equipe2", atelier2);
		} catch (Exception e) {
			fail("Exception in creation");
		}

		Collection roots = null;
		try {
			roots = StructureManager.getRootNodes();
		} catch (Exception e) {
			fail("Access to the root nodes");
		}
		assertEquals(2, roots.size());
	}
}
